package com.heima.wemedia.controller.v1;

import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.wemedia.dtos.WmNewsDto;
import com.heima.model.wemedia.dtos.WmNewsPageReqDto;
import com.heima.wemedia.service.WmNewsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/v1/news")
public class WmNewController {
    @Autowired
    private WmNewsService wmNewsService;

    @PostMapping("/list")
    public ResponseResult findList(@RequestBody WmNewsPageReqDto dto) {
        return wmNewsService.findList(dto);

    }
    @PostMapping("/submit")
    public  ResponseResult submit(@RequestBody WmNewsDto wmNewsDto){
        return wmNewsService.submit(wmNewsDto);
    }
    //查看文章的详情
    @GetMapping("/one/{id}")
    public ResponseResult details(@PathVariable Integer id){
        return wmNewsService.details(id);
    }
    //文章删除
    @GetMapping("/del_news/{id}")
    public ResponseResult delNews(@PathVariable Integer id){
        return  wmNewsService.delNews(id);
    }
    //文章上下架
    @PostMapping("/down_or_up")
     public ResponseResult dowmOrup(@RequestBody WmNewsDto wmNewsDto){
        return wmNewsService.downOrUp(wmNewsDto);
    }
}
